home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
GRAPH_FO
/
CFONTORA.C
next >
Wrap
Text File
|
1991-03-26
|
3KB
|
108 lines
/******************************************************************************
CFontorama.c
A panorama that supports Font and Size menus, updating them properly
in UpdateMenus().
SUPERCLASS = CPanorama.c
Copyright ⌐ 1991 Maarten Meijer. All rights reserved.
CIS 100016,1764; FidoNet 2:512/114
*******************************************************************************/
#include <CBartender.h>
#include <Commands.h>
#include "CFontorama.h"
extern CBartender *gBartender;
/******************************************************************************
DoCommand
Handle the font and size commands for the current garfport.
*******************************************************************************/
void CFontorama::DoCommand(long theCommand) {
Str255 itemName;
long number;
short fontID, fontSize;
if (theCommand < 0) {
switch (HiShort(-theCommand)) {
case MENUfont:
gBartender->GetCmdText(theCommand, itemName);
GetFNum(itemName, &fontID);
Prepare();
TextFont(fontID);
Refresh();
break;
case MENUsize:
gBartender->GetCmdText(theCommand, itemName);
StringToNum(itemName, &number);
Prepare();
fontSize = number;
TextSize(fontSize);
Refresh();
break;
default:
inherited::DoCommand(theCommand);
break;
}
} else {
switch(theCommand) {
default:
inherited::DoCommand(theCommand);
break;
}
}
}
/******************************************************************************
UpdateMenus
Set the font and size menus to the current settings of the GrafPort.
It outlines the existing sizes for the selected font.
*******************************************************************************/
void CFontorama::UpdateMenus() {
register GrafPtr grafPtr;
short fontSize, fontID;
Str255 fontStr;
short item, noItems;
long size;
MenuHandle menu;
/* the font and size menus should allways be enabled */
grafPtr = GetMacPort();
fontSize = grafPtr->txSize;
fontID = grafPtr->txFont;
GetFontName(fontID, fontStr);
item = gBartender->FindItemText(MENUfont, fontStr);
CheckItem(GetMHandle(MENUfont), item, true);
NumToString((long)fontSize, fontStr);
menu = GetMHandle(MENUsize);
item = gBartender->FindItemText(MENUsize, fontStr);
CheckItem(menu, item, true);
noItems = CountMItems(menu);
for(item = 1 ; item < noItems; item++) {
GetItem(menu, item, fontStr);
StringToNum(fontStr, &size);
if( RealFont(fontID, (short)size) )
SetItemStyle(menu, item, outline);
else
SetItemStyle(menu, item, 0);
}
inherited::UpdateMenus();
}